//
//  GTMainViewController.swift
//  swiftWEIbo
//
//  Created by mac－gt on 15/11/23.
//  Copyright © 2015年 mac－gt. All rights reserved.
//

import UIKit

class GTMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.tabBar.tintColor=UIColor.orangeColor()
        let homeVC = GTHomeViewController()
        addChildViewController(homeVC, title: "首页", imageName: "tabbar_home")
        let messageVC=GTMessageViewController()
       addChildViewController(messageVC, title: "消息", imageName: "tabbar_message_center")
        let discoverVC=GTDiscover()
        addChildViewController(UIViewController())
        addChildViewController(discoverVC, title: "发现", imageName: "tabbar_discover")
        let profileVC=GTProfileViewController()
         addChildViewController(profileVC, title: "我", imageName: "tabbar_profile")
    }
    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        let btnWidth=self.tabBar.bounds.size.width/5
        self.tabBar.addSubview(addBtn)
        addBtn.frame=CGRect(x: 2*btnWidth, y: 0, width: btnWidth, height: tabBar.bounds.height)
        
    }
func addChildViewController(viewController: UIViewController,title: String,imageName: String){
    viewController.title=title
    viewController.tabBarItem.image=UIImage(named: imageName)
    viewController.tabBarItem.selectedImage=UIImage(named: imageName+"_highlighted")
     addChildViewController(UINavigationController(rootViewController: viewController))

    }

private var addBtn: UIButton={
    let btn=UIButton()
    btn.setBackgroundImage(UIImage(named: "tabbar_compose_button"), forState: UIControlState.Normal)
    btn.setBackgroundImage(UIImage(named: "tabbar_compose_button_highlighted"), forState: UIControlState.Highlighted)
    btn.setImage(UIImage(named: "tabbar_compose_icon_add"), forState: UIControlState.Normal)
    btn.setImage(UIImage(named: "tabbar_compose_icon_add_highlighted"), forState: UIControlState.Highlighted)
    return btn
    
}()
}